import { createStore } from 'vuex' ;
import axios from 'axios';

const store = createStore({
    state(){
        return {
            goods: [],
            ratings:[],
            seller:{},
        };
    },
    getters: {},
    mutations: {
        setData( store , payload ){
            // console.log( '111' );
            store.goods = payload.goods;
            store.ratings = payload.ratings;
            store.seller = payload.seller;
            console.log( store.goods , store.ratings , store.seller );
        },
    },
    actions: {
        async getData( { commit } ){
            const {data} = await axios.get( '/api/goods' );
            console.log( data );
            commit( 'setData' , data );
        }
    },
    modules: {},
});
export default store ;